package com.yehuishou.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yehuishou.dao.BidrecordDao;
import com.yehuishou.dao.UserDao;
import com.yehuishou.pojo.BidItem;
import com.yehuishou.pojo.Bidrecord;
import com.yehuishou.service.BidrecordService;

@Service
public class BidrecordServiceImpl implements  BidrecordService {

	@Resource
	private BidrecordDao bidrecordDao;
	
	@Resource
	private UserDao userDao;
	
	@Override
	public List<Bidrecord> getBidRecord(String phone, String bidname,String bid) {
		Bidrecord record = new Bidrecord();
		if(phone!=null&&phone!="") {
			record.setPhone(phone);
		}
		 if(bidname!=null&&bidname!="") {
			 record.setBidname(bidname);  
		 }
		 
		 if(bid!=null&&bid!="") {
			 record.setBid(Integer.parseInt(bid));
		 }
		 System.out.println(record);
		return bidrecordDao.getBidRecord(record);
	}

	
	@Override
	public void deleteBidRecord(Integer id) {
		
		bidrecordDao.deleteBidRecord(id);
	}


	@Override
	public Bidrecord getOneById(Integer id) {
		
		return bidrecordDao.getOneById(id);
	}


	@Override
	public List<Bidrecord> getBidRecord(Integer bid) {
		// TODO Auto-generated method stub
		Bidrecord br = new Bidrecord();
		br.setBid(bid);
		return bidrecordDao.getBidRecord(br);
	}



	@Override
	public void updateRecord(List<Integer> ids, Integer status) {
		
		    Bidrecord re = new Bidrecord();
		    re.setRe_status(status);
		for(int i=0;i<ids.size();i++) {
			re.setId(ids.get(i));
			bidrecordDao.updateBidrecordById(re);
			
			}
		
	}


	@Override
	public void updateRecordById(Bidrecord re) {
		bidrecordDao.updateBidrecordById(re);
		
	}


	@Override
	public void deleteBidRecords(Integer[] ids) {
		bidrecordDao.deleteBidRecords(ids);
		
	}
	
	

}
